const app = getApp()


Page({
    data: {
        // isshow:undefined,
        alllist:[],
        isshows:false,
        hinddshow:false,
        countdownValue: '', // 倒计时值
        formatcountdown:'',
        targetLatitude: 39.908722, // 目标终点的纬度
        targetLongitude: 116.397496, // 目标终点的经度
        distance:'',//用户与目标终点之间的距离
        refreshing: false, // 下拉刷新状态
        recharge_rate:[],
        UserImage:'',
        ids:"",
        service: false,
        markers: [], //地图参数：
        latitude: "", //纬度 
        longitude: "", //经度
        user: {},
        city: {},
        lat: '',
        lon: '',
        order_id: 0,
        i_mark:'',
        i_distance:'',
        i_price:'',
        i_search:'',
        // 轮播
        imgUrls: [],
        store_label:[],
        indicatorDots: true,
        vertical: true,
        autoplay: true,
        interval: 2000,
        duration: 500,
        // 公告
        msgList: [],
        // 首页列表
        // tabTxt: ['智能排序', '距离', '价格','筛选'],//分类
        // tabTxt: ['智能排序','筛选'],//分类
        tab: [true, true, true,true],
        tab_active: [true, true, true,true],
        pinpaiList: [{ 'id': '1', 'title': '品牌1' }, { 'id': '2', 'title': '品牌2' }],
        pinpai_id: 0,//品牌
        pinpai_txt: '',
        jiage_id: 0,//价格
        jiage_txt: '',
        xiaoliang_id: 0,//销量
        xiaoliang_txt: '',
        sx_id: 0,//销量
        sx_txt: '',
        details: [],
        circular: true, //是否采用衔接滑动
        indicatorDots: true, //是否显示面板指示点
        scrollTop: '', //滑动的距离
        navFixed: false, //导航是否固定
        currentData: 0,
        canIUseGetUserProfile: false,
        agreed: false,//用户隐私协议
        user_privacy_agreement_title:'',
        user_privacy_agreement_des:'',
        animationData:'',
        mobileShow:false
    },
    // 轮播图
    getBanner: function (e) {
        app.ajax({
            url: '/api/index/getIndexHeaderAggregate',
            success: res => {
                if (res.code == 1) {
                    this.setData({
                        imgUrls: res.data.banner_list,
                        msgList:res.data.notice,
                        order_info:res.data.order
                    })
                    wx.setStorageSync('msgLists',res.data.notice[0]);
               
                }
            }
        })
    },
     // 选项卡
  filterTab: function (e) {
    var data = [true, true, true,true], tab_active = [true, true, true,true], index = e.currentTarget.dataset.index;
    data[index] = !this.data.tab[index];
    tab_active[index] = !this.data.tab_active[index];
    this.setData({
      tab: data,
      tab_active:tab_active
    })
  },
  //监听滑动
  layoutScroll: function(e) {
    this.data.scrollTop = this.data.scrollTop * 1 + e.detail.deltaY * 1;
    // console.log(this.data.scrollTop)
    // console.log(this.data.navFixed)
    /** 我这里写了固定值 如果使用rpx 可用query可以动态获取其他的高度 然后修改这里值 */
    /** 获取方法参考文档 */

    /** scrollTop 在模拟器上检测不是太灵敏 可在真机上测试 基本上不会出现延迟问题 */
    var navtopHeight = 100;
    if (this.data.scrollTop >= -navtopHeight) {
    //   this.setData({
    //     navFixed: false
    //   })
    // } else {
    //   this.setData({
    //     navFixed: true
    //   })
    }
  },
  //筛选项点击操作
  filter: function (e) {
    var self = this,
     id = e.currentTarget.dataset.id,
      txt = e.currentTarget.dataset.txt, 
      distance = e.currentTarget.dataset.distance, 
      price = e.currentTarget.dataset.price, 
      lableid = e.currentTarget.dataset.lableid, 
      comparison_operator = '',
      tabTxt = this.data.tabTxt;
    if(distance == 1){
        comparison_operator = '{"comparison_operator":"lt","num_arr":[3000]}'
    }else if(distance == 2){
        comparison_operator = '{"comparison_operator":"between","num_arr":[3000,5000]}'
    }
    else if(distance == 3){
        comparison_operator = '{"comparison_operator":"between","num_arr":[5000,10000]}'
    }
    else if(distance == 4){
        comparison_operator = '{"comparison_operator":"gt","num_arr":[10000]}'
    }else{
        comparison_operator = ''
    }
    switch (e.currentTarget.dataset.index) {
      case '0':
        tabTxt[0] = txt;
        self.setData({
          tab: [true, true, true,true],
          tabTxt: tabTxt,
          pinpai_id: id,
          pinpai_txt: txt,
          i_mark:price,
          i_price:price,
          i_distance:comparison_operator,
          xiaoliang_id: id,
          xiaoliang_txt: txt,
        });
        break;
      case '1':
        tabTxt[1] = txt;
        self.setData({
          tab: [true, true, true,true],
          tabTxt: tabTxt,
          jiage_id: id,
          jiage_txt: txt,
          i_distance:comparison_operator
        });
        break;
      case '2':
        tabTxt[2] = txt;
        self.setData({
          tab: [true, true, true,true],
          tabTxt: tabTxt,
          xiaoliang_id: id,
          xiaoliang_txt: txt,
          i_price:price
        });
        break;

        case '3':
            tabTxt[3] = txt;
            self.setData({
              tab: [true, true, true,true],
              tabTxt: tabTxt,
              sx_id: id,
              sx_txt: txt,
              i_search:price,
              i_price:price,
              i_distance:comparison_operator,
              lableid:lableid
            });
            break;
        }
    //数据筛选
    self.getStores();
  },
 
  //加载数据
  getDataList: function () {
  

        //调用数据接口，获取数据
        wx.setStorageSync('location', {
            lat: res.latitude,
            lon: res.longitude,
        });
        var city = wx.getStorageSync('city');
        if (city) {
            this.setData({
                city: city
            });
       
            this.getStores();
        } else {
            this.getCity();
        }
    },
    //事件处理函数
    btnOK:function(event){
        this.ids = event.currentTarget.dataset.id;
       if(this.ids==1){
        wx.navigateTo({
            url: '/pages/join/join'
        })
      
       }else if(this.ids==2){
    //     var lat = this.data.details[0].lat;
    //     var lon = this.data.details[0].lon;
    //     var name = this.data.details[0].name;
    //     var address = this.data.details[0].address;
    //    console.log(lat,lon,'lonlon跳转了')
    //     wx.getLocation({
    //       type: 'gcj02',
    //       success: function(res) {
    //         wx.openLocation({
    //           latitude:Number(lat) ,
    //           longitude:Number(lon) ,
    //           scale: 28,
    //           name: name,
    //           address: address
    //         });
    //       },
    //       fail: function(err) {
    //         console.log(err);
    //       },
    //       complete: function(info) {
    //         console.log(info);
    //       }
    //     });
        //  return wx.showToast({
        //    title: '优惠券暂未开放',
        //    icon:'none'
        //  })
        wx.navigateTo({
            url: '/pages/coupon/coupon?indexs='+"quxiao"
        })
       }else if(this.ids==3){
           this.setData({
            isshows:true
           })
        // var tel = wx.getStorageSync('tel');
        // if(tel)
        // wx.makePhoneCall({
        //     phoneNumber: tel,
        //     success: function () {},
        // })
       }else{
        wx.navigateTo({
            url: '/pages/my_order/my_order',
          })

       }
    },
    handle_service: function() {
        this.setData({
            service: true
        })
    },
    stopBubb: function() {
        return false
    },

    close_layer: function() {
        this.setData({
            service: false,
        })
    },
    select_city: function() {
        wx.navigateTo({
            url: '/pages/select_city/select_city'
        })
    },
    search_result: function() {
        // if(!this.data.user.mobile) return false;
        wx.navigateTo({
            url: '/pages/search_info/search_info'
        })
    },
    opening_code: function() {
        wx.navigateTo({
            url: '/pages/opening_code/opening_code?order_id=' + this.data.order_id
        })
    }, 
    history_order: function() {
        wx.navigateTo({
            url: '/pages/history_order/history_order'
        })
    },
    callPhone(e) {
        var tel = wx.getStorageSync('tel');
        if(tel)
        wx.makePhoneCall({
            phoneNumber: tel,
            success: function() {},
        })
    },
    callStore(e) {
      var tel = e.target.dataset.tel;
      if(tel)
      wx.makePhoneCall({
          phoneNumber: tel,
          success: function() {},
      })
  },
  listenerBtnGetLocation:function(e){
    var lat = e.currentTarget.dataset.lat;
    var lon = e.currentTarget.dataset.lon;
    var name = e.currentTarget.dataset.name;
    var address = e.currentTarget.dataset.address;
   console.log(lat,lon,'lonlon跳转了')
   
    wx.getLocation({
      type: 'gcj02',
      success: function(res) {
        wx.openLocation({
          latitude:Number(lat) ,
          longitude:Number(lon) ,
          scale: 28,
          name: name,
          address: address
        });
      },
      fail: function(err) {
        console.log(err);
      },
      complete: function(info) {
        console.log(info);
      }
    });
  
},
    use_explain: function() {
        wx.navigateTo({
            url: '/pages/use_explain/use_explain'
        })
    },
    common_problem: function() {
        wx.navigateTo({
            url: '/pages/common_problem/common_problem'
        })
    },
    //首页
    goindex: function(e) {
        wx.redirectTo({
            url: '/pages/index/index'
        })
    },
    select_teaRoom: function() {
        wx.navigateTo({
            url: '/pages/search_result/search_result'
        })
    },
     //我的订单
     myorder: function() {
        wx.redirectTo({
            url: '/pages/my_order/my_order'
        })
    },
    //我的
    my: function() {
        wx.redirectTo({
            url: '/pages/my/my'
        })
    },
    moveToLocation: function() {
        var mapCtx = wx.createMapContext('map'); //wxml中map标签的id值
        mapCtx.moveToLocation();
    },
    markertap: function(e){
        if(!this.data.user.mobile){
            wx.showToast({
                title: '请先登录',
                icon: 'none'
            })
            return false;
        }
        console.log(e);
        if(e.markerId){
            wx.navigateTo({
              url: '/pages/book/book?id=' + e.markerId
            })
        }
    },
    onLoad: function(options) {

     let allflag=wx.getStorageSync('allflag')
        if(allflag){
            this.setData({
                agreed:false
            })
        }
        // this.agreePrivacy()//确认勾选隐私协议
       
        this.sketchhaderl()

        setTimeout(()=>{
            const agreed = wx.getStorageSync('agreedPrivacy');
            const rechargecontent=wx.getStorageSync('rechargecontent')
       this.setData({
        agreed:true,
        showPopup:true
       })

       if (agreed||rechargecontent) {
       this.setData({
           agreed: false,
           showPopup:false
       });
       }
        },0)
        const scene = decodeURIComponent(options.scene)
        wx.setStorageSync('inv_code', scene);
        // 下面
        // if (wx.getUserProfile) {
        //     this.setData({
        //         canIUseGetUserProfile: true
        //     })
        // }
      
           if (wx.getUserProfile) {
            this.setData({
                canIUseGetUserProfile: true
            })
        }
        // this.getLocation();
        this.getSite();
        this.getStores();
        this.recharge()
        
    },
    getSite: function(){
        app.ajax({
            url: '/api/index/getSite',
            success: res => {
                if(res.code == 1){
                    var site = res.data;
                    this.setData({
                     alllist:res.data.tel
                    })
                    wx.setStorageSync('tel', site.tel[0]);
                    wx.setStorageSync('instructions', site.instructions);
                    wx.setStorageSync('about', site.about);
                    wx.setStorageSync('name', site.name);
                    wx.setStorageSync('explain', site.explain);
                }
            }
        })
    },
    // 获取首页标签
    getLabelList: function(){
        app.ajax({
            url: '/api/index/getLabelList',
            success: res => {
                if(res.code == 1){
                    wx.setStorageSync('store_label', res.data)
                    this.setData({
                        store_label: res.data,
                    });
                }
            }
        })
    },
    getLocation: function() {
        wx.getLocation({
            type: 'gcj02',
            success: res => {
                this.setData({
                    lat: res.latitude,
                    lon: res.longitude,
                });
                wx.setStorageSync('location', {
                    lat: res.latitude,
                    lon: res.longitude
                });
                var city = wx.getStorageSync('city');
                if (city) {
                    this.setData({
                        city: city
                    });
                    this.getStores();
                } else {
                    this.getCity();
                }
            },
            fail:err=>{
                // showModal showToast
                wx.showToast({  
                    title: '定位失败',  
                    icon: 'none',  
                    duration: 2000  
                  });  
            // wx.removeStorageSync('key')
            }
        })
    },
    getCity: function() {
        app.ajax({
            url: '/api/index/getCity',
            data: {
                lat: this.data.lat,
                lon: this.data.lon
            },
            success: res => {
                if (res.code == 1) {
                    var city = res.data;
                    wx.setStorageSync('city', city);
                    this.setData({
                        city: city
                    });
                    this.getStores();
                }
            }
        })
    },
    getStores: function() {
        app.ajax({
            url: '/api/index/stores',
            data: {
                lat: this.data.lat,
                lon: this.data.lon,
                city_id: this.data.city.id,
                mark:this.data.i_mark,
                distance_where:this.data.i_distance,
                order_price:this.data.i_price,
                search:this.data.i_search,
                label_id:this.data.lableid,
            },
            success: res => {
                if (res.code == 1) {
                    wx.setStorageSync('stores', res.data);
                   
                    var markers  =  [];
                    var address = [];
                    for (var i in res.data) {
                        var row = res.data[i];    
                        address.push({
                          id: row.id,
                          address: row.address,
                          lat: row.lat,
                          lon: row.lon,
                          name: row.name
                        });

                        if(row.rooms.length > 0){
                            markers.push({
                                id: row.rooms[0].id,
                                latitude: parseFloat(row.lat),
                                longitude: parseFloat(row.lon),
                                iconPath: '/images/marker.png',
                                width: 24,
                                height: 23,
                                callout: {
                                    content: row.name + '(' + row.distance + ')',
                                    color: '#fff',
                                    fontSize: 10,
                                    borderRadius: 5,
                                    bgColor: '#1CA3BF',
                                    padding: 5,
                                    display: 'ALWAYS'
                                }
                            });
                        }
                    }
                    this.setData({
                        userLatitude:res.data[0].lat,
                        userLongitude:res.data[0].lon,
                        markers: markers,
                        details:res.data,
                        address:address,
                    })
                    this.calculateDistance()
                    
                
                } else {
                    wx.removeStorageSync('stores');
                    // wx.showToast({
                    //     title: '空空如也',
                    //     icon: 'none'
                    // })
                    this.setData({
                        markers: [],
                        details:[]
                    })
                }
            }
        })
    },
    onShow: function() {
        let allflag=wx.getStorageSync('allflag')
        if(allflag){
            this.setData({
                agreed:false
            })
        }
        // this.agreePrivacy()//确认勾选隐私协议
        //    // 检查用户是否已同意隐私协议，如果已同意则更新数据
        setTimeout(()=>{
            const agreed = wx.getStorageSync('agreedPrivacy');
            const token=wx.getStorageSync('token')
            const  rechargecontent=wx.getStorageSync('rechargecontent')
       this.setData({
        agreed:true
       })

       if (agreed) {
       this.setData({
           agreed: false
       });
       }
       if (token){
        this.setData({
            canIUseGetUserProfiles:true
        })
        if(rechargecontent){
            this.setData({
                showPopup:false
            })

        }
     this.getLocation()
    }
        },0)
        // this.loginhaderl()
        // 下面
        var city = wx.getStorageSync('city');
       
        if (city && city.id != this.data.city.id) {
            this.setData({
                city: city
            });
            if (this.data.lat && this.data.lon) this.getStores();
        }
        // var mobileShow=wx.getStorageSync('user')||{}
        // console.log(JSON.parse(mobileShow).mobile,mobileShow,'mobileShowmobileShowmobileShow')
        // if(JSON.parse(mobileShow).mobile){
        //     this.setData({
        //         mobileShow:true
        //     })
        // }
    
     
        this.getNewOrder();
        // this.getBanner();
        this.getLabelList();
        this.userinfo();
        this.getBanner()
    
    },



    userinfo: function() {
      
     
        app.ajax({
            url: '/api/user/userinfo',
            success: res => {
                if (res.code == 1) {
                    wx.setStorageSync('user', res.data);
                    this.setData({
                        user: res.data
                    })
                }
            }
        })
    },
    getNewOrder: function(){
        app.ajax({
            url: '/api/user/newOrder',
            success: res => {
                if(res.code == 1){
                    this.setData({
                        order_id: res.data
                    })
                }
            }
        })
    },
    login: function(e) {
        // console.log(e,this.data.canIUseGetUserProfile,'this.data.canIUseGetUserProfile');

        if (this.data.canIUseGetUserProfile){
            console.log('getUserProfile')
            wx.getUserProfile({
                desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
                success: (res) => {
                    console.log(res,'用户完善用户的资料')
                    if (!res.userInfo) {
                        wx.showToast({
                            title: '未获取到用户信息',
                            icon: 'none'
                        });
                        return;
                    }
                    wx.setStorageSync('userinfo', res.userInfo);
                    wx.navigateTo({
                        url: '/pages/login/login'
                    })
                }
            })
        } else {
            if (!e.detail.userInfo) {
                wx.showToast({
                    title: '未获取到用户信息',
                    icon: 'none'
                });
                return;
            }
            wx.setStorageSync('userinfo', e.detail.userInfo);
            wx.navigateTo({
                url: '/pages/login/login'
            })
        }
      

     
    },
    xiangqing: function (e) {
        //   this.getLocation()
    
        // let location=wx.getStorageSync('location');
        // if(!location){
        //     return
        // }
        // wx.showModal({  
        //     title: '提示',  
        //     content: '您尚未开启定位服务，请点击确定以允许小程序使用您的定位服务',  
        //     success: function(res) {  
        //       if (res.confirm) {  
        //         // 用户点击确定按钮，获取定位信息  
        //         wx.getLocation({  
        //           type: 'wgs84',  
        //           success: function(res) {  
        //             // 获取到定位信息，进行相关操作  
        //             console.log('经度：', res.longitude);  
        //             console.log('纬度：', res.latitude);  
        //             // 在这里你可以将经纬度信息发送到后端或其他所需操作  
        //           },  
        //           fail: function(err) {  
        //             // 获取定位信息失败，进行相关处理  
        //             console.log('获取定位失败', err);  
        //           }  
        //         });  
        //       } else {  
        //         // 用户点击取消按钮，跳转到手机上的设置页面  
        //         wx.navigateTo({  
        //           url: '/pages/settings/settings' // 设置页面的路径  
        //         });  
        //       }  
        //     }  
        //   });  
       
        var id = e.target.dataset.id;
        var distance=e.target.dataset.distance
        wx.navigateTo({
            url: '/pages/xiangqing/xiangqing?id=' +id+'&distance='+distance,
        })

    },
    xiangqing1: function (e) {
        var id = e.currentTarget.dataset.id;
        console.log(e);
        console.log(id);
        wx.navigateTo({
            url: '/pages/xiangqing/xiangqing?id=' +id,
        })
    },
    order_subscribe:function(e){
        var id = e.target.dataset.id;
        wx.navigateTo({
            url: '/pages/unsettled/unsettled?order_id=' +id,
            // url: '/pages/opening_code/opening_code?order_id=' +id,
        })
    },
    //公告弹窗
    openTip:function(e){
      var name = e.currentTarget.dataset.name || ''
      wx.showModal({
        title: '详情',
        content: name,
        showCancel:false,
        success (res) {
          if (res.confirm) {
            console.log('用户点击确定')
          } else if (res.cancel) {
            console.log('用户点击取消')
          }
        }
      })
    },

    goyz: function(e) {
      var index = e.currentTarget.dataset.t;
      if(index == 1){
        wx.navigateTo({
             url: '/pages/company_intr/company_intr'
      });
      }
      if(index == 2){
        wx.navigateTo({
          url: '/pages/duihuan/duihuan?dhkey=2'
      });
      }
      if(index == 3){
    //  return   wx.showToast({
    //       title: '余额充值暂未开放',
    //       icon:'none'
    //     })
        wx.navigateTo({
          url: '/pages/account_chongzhi/account_chongzhi'
      });
      }
      if(index == 4){
        wx.navigateTo({
        //   url: '/pages/company_intr/company_intr'
           url: '/pages/common_problem/common_problem'
      });
      }
  },
    //   时间选择器
    bindTimeChange: function(e) {
        console.log('picker发送选择改变，携带值为', e.detail.value)
        this.setData({
        time: e.detail.value
        })
    },
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {
        wx.showLoading({
            title: '加载中...'
          });
          // 模拟异步请求最新数据
          setTimeout(() => {
            // 在这里执行获取最新数据的逻辑，比如调用接口获取数据
            this.getStores()
            this.getBanner()
            // 数据获取完成后隐藏加载提示
            wx.hideLoading();
            // 停止当前页面下拉刷新
            wx.stopPullDownRefresh();
          }, 1000);
    },
    onUnload:function(){

    },
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },
    goyzs: function(){
    wx.navigateTo({
        url: '/pages/notices/notices'
    });
    },
    // 用户隐私协议
    agreePrivacy: function() {
      
     // 用户点击同意按钮后的逻辑处理
    // 将同意状态保存到本地存储，并更新数据
    wx.setStorageSync('agreedPrivacy', true);
    this.setData({
      agreed: false
    });
    this.getLocation()
      },
      denyPrivacy: function() {
          this.setData({
            agreed:!this.data.agreed 
          })
          wx.showToast({  
            title: '定位失败',  
            icon: 'none',  
            duration: 2000  
          });  
      },
      Protectinghaderl(){
         wx.navigateTo({
           url: '/pages/userprivacy/userprivacy',
         })
      },
      sketchhaderl(){
        app.ajax({
            url: '/api/login/getUserPrivacyAgreement',
            success: res => {
                if (res.code == 1) {
                    this.setData({
                        user_privacy_agreement_des:res.data.user_privacy_agreement_des,
                        user_privacy_agreement_title:res.data.user_privacy_agreement_title
                    })
                  wx.setStorageSync('user_privacy_agreement_des',res.data.user_privacy_agreement_des )   
                 
                }
            }
        })
      },
      detailshaderl(){
        wx.navigateTo({
          url: '/pages/Invitationdetails/Invitationdetails',
        })
      },
      loginhaderl: function () {
        wx.login({
            success: res => {
        
                app.ajax({
                    url: '/api/index/login',
                    data: {
                        code: res.code,
                    },
                    success: res => {
                        console.log(res);
                        if (res.code == 1) {
                            var user = wx.getStorageSync('user');
                            wx.setStorageSync('token', res.data.token);
                            wx.setStorageSync('deposit', res.data.deposit);
                            wx.setStorageSync('money', res.data.money);
                            if(!user || user.id != res.data.id) wx.setStorageSync('user', res.data);
                        }
                    }
                });
            }
        });
    },
    userhader(){
    //  let  avatarUrl=wx.getStorageSync('avatarUrl')
    //  this.setData({
    //     UserImage:avatarUrl
    //   })
        wx.getUserProfile({
            desc: '用于完善会员资料', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
            success: (res) => {
              const userInfo = res.userInfo;
              this.setData({
                UserImage:userInfo.avatarUrl
              })
             
            },
            fail: (error) => {
              console.error(error);
            }
          });
    },
    openPopup: function() {
        this.setData({
          showPopup: true
        });
      },
      closePopup: function() {
        wx.setStorageSync('rechargecontent',true)
        this.setData({
          showPopup: false
        });
        wx.navigateTo({
          url: '/pages/account_chongzhi/account_chongzhi',
        })
      },
      cancelPopup: function() {
        wx.showToast({
          title: '已取消',
          icon: 'none'
        });
        wx.setStorageSync('rechargecontent',true)
        this.setData({
          showPopup: false
        });
      
      },
      recharge(){
        app.ajax({
            url: '/api/index/recharge_info',
            success: res => {
                if(res.code == 1){
                    this.setData({
                        // recharge_info: res.data.desc,
                        recharge_rate:res.data.rate
                    })
                }else{
                }
            }
        }, 1);
        
      },
    // 计算用户与目标终点之间的距离
  calculateDistance() {
    const { userLatitude, userLongitude, lat, lon } = this.data;

    // 使用 Haversine 公式计算两个坐标之间的距离
    const radLat1 = userLatitude * Math.PI / 180.0;
    const radLat2 = lat * Math.PI / 180.0;
    const a = radLat1 - radLat2;
    const b = userLongitude * Math.PI / 180.0 - lon * Math.PI / 180.0;
    let s =
      2 *
      Math.asin(
        Math.sqrt(
          Math.pow(Math.sin(a / 2), 2) +
            Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)
        )
      ) *
      6378.137 *
      1000;

    s = Math.round(s * 100) / 100; // 保留两位小数

    this.setData({
      distance: s,
    });
  },
  hinddshowhaderl(){
      this.setData({
        hinddshow:!this.data.hinddshow
      })
  },
  handleButtonClick() {
    // 处理按钮点击事件
    console.log("按钮被点击了");
    // 在这里可以编写打开开门/续租的逻辑
  },
  handleButtonClick1(){
    wx.navigateTo({
      url: '/pages/my_order/my_order',
    })
  },
  handleButtonClick2(){
    console.log(222)
    wx.navigateTo({
      url: '/pages/my_order/my_order',
    })
  },
  contacts(e){
       let tel=e.currentTarget.dataset.item
      if(tel)
        wx.makePhoneCall({
            phoneNumber: tel,
            success: function () {},
        })
  },
  cancellationOK(){
      this.setData({
        isshows:!this.data.isshows
      })
  }




})